package pkg

import (
	"2301house/config"
	"encoding/json"
	"github.com/Baidu-AIP/golang-sdk/aip/censor"
	"log"
)

type TextCensorResp struct {
	ConclusionType uint64 `json:"conclusionType"`
}

func TextCensor(message string) bool {
	var Baidu = config.ConFig.Baidu
	client := censor.NewClient(Baidu.Ak, Baidu.Sk) //百度账号
	//如果是百度云ak sk,使用下面的客户端
	res := client.TextCensor(message)
	log.Println(res)
	var resp TextCensorResp
	_ = json.Unmarshal([]byte(res), &resp)
	log.Println(resp)
	if resp.ConclusionType == 1 {
		return true
	}
	return false
}
